package com.example.demo.mapper;

import com.example.demo.entity.Classes;
import com.example.demo.entity.Subscribe;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassesMapper {
    @Select("select * from classes")
    List<Classes> findAll();

    @Insert("insert into sys_user(username,password,email,phone,nickname,address) " +
            "VALUES(#{username},#{password},#{email},#{phone},#{nickname},#{address});")
    int insert(Classes classes);

    //查询预约实验室的现有容量
    @Select("select count from classes where name=#{name}")
    int existCount(@Param("name") String name);

    //查询预约实验室的编号
    @Select("select id from classes where labType=#{type} and lab=#{number}")
    int labId(@Param("labType") int labType, @Param("lab") String lab);

    //修改实验室的现有容量
    @Update("update classes set count=#{count} where id={#id}")
    int editCount(@Param("count") int count,@Param("id") int id);

    //分页查询数据,多个参数需要增加注解标识指定参数
    @Select("select * from classes limit #{pageNum},#{pageSize}")
    List<Classes> selectPage(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    //查询记录总数
    @Select("select count(*) from classes")
    Integer selectTotal();

    //查询不同类型的所有实验室数据
    @Select("select * from classes where type=#{type}")
    List<Classes> labTypeSelect(@Param("type") int type);

    //查询不同类型的所有实验室数据,分页显示
    @Select("select * from classes where type=#{type} limit #{pageNum},#{pageSize}")
    List<Classes> labTypeSelectPage(@Param("type") int type,@Param("pageNum") Integer pageNum,@Param("pageSize") Integer pageSize);

    //根据id查询实验室详情
    @Select("select * from classes where id=#{id}")
    Classes getDetail(@Param("id") Integer id);
}

